package Button
{
	import flash.display.Sprite;	
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	import Const.*;
	
	public final class UglyCheckBox extends Sprite
	{
		private var _theCircle : Sprite = new Sprite();
		private var _isActive : Boolean = false;
		
		private var _text:TextField = new TextField();
		private var _textFormat : TextFormat = new TextFormat();
		
		private var _id:int = CheckBoxIDs.CHECKBOXID_NONE;
		
		public function UglyCheckBox(text:String, id:int)
		{
			super();
			
			_id = id;
			
			//Set Button Properties
			this.mouseChildren = false;
			this.buttonMode = true;
			
			with(this.graphics)
			{			
				//Draw the border
				beginFill(0x000000, 1);
				drawRect(0, 0, 24, 24);
				endFill();
				
				//Draw the rect
				beginFill(0xFFFFFF, 1);
				drawRect(2, 2, 20, 20);
				endFill();		
			}
			
			with(_theCircle.graphics)
			{
				beginFill(0x000088, 1);
				drawCircle(0, 0, 10);
				endFill();
			}
			
			_theCircle.x = 12;	//Jeje		
			_theCircle.y = 12;
			
			//Set Button Text
			if(text != "")
			{						
				//Setting some native properties			
				_textFormat.size = 17;
				_textFormat.bold;
				//_textFormat.align = TextFormatAlign.CENTER;
				_text.defaultTextFormat = _textFormat;
				
				//_text.autoSize = "center";
				_text.selectable = false;
				
				//Assigning the text
				_text.text = text;
				
				_text.x = 30;
				
				this.addChild(_text);
			}
		}
		
		public function activate(act:Boolean) : void
		{
			if(act && !_isActive)
			{				
				this.addChild(_theCircle);
				_isActive = true;
			}
			else if(!act && _isActive)
			{
				removeChild(_theCircle);
				_isActive = false;
			}
		}
		
		public function isActive() : Boolean
		{
			return _isActive;
		}
		
		public function getId() : int
		{
			return _id;
		}
	}
}